package ru.st.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.*;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;

public class AddFilmPage extends InternalPage {

	public AddFilmPage(PageManager pages) {
		super(pages);
		
	}

	@FindBy(name="name")
	private WebElement TitleField;
	
	@FindBy(name="year")
	private WebElement YearField;
	
	@FindBy(name="notes")
	private WebElement NotesField;
	
	@FindBy(id="submit")
	private WebElement SaveButton;
	
	public AddFilmPage SetTitle (String text) {
		TitleField.sendKeys(text);
		return this;
	}
	
	public AddFilmPage SetYear (String text) {
		YearField.sendKeys(text);
		return this;
	}
	
	public AddFilmPage SetNotes (String text) {
		NotesField.sendKeys(text);
		return this;
	}
	
	public AddFilmPage ensurePageLoaded() {
	    super.ensurePageLoaded();
	    wait.until(presenceOfElementLocated(By.id("imdbsearchform")));
	    return this;
	  }
	
	public void ClickSaveButton() {
		SaveButton.click();
	}

}
